package com.itheima.web;

import com.itheima.daomain.User;
import com.itheima.service.UserpageService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sound.midi.Soundbank;
import java.io.IOException;
import java.util.List;

/**
 * @Descriptionn:test
 * @Create by:依然
 * @Date:2021/11/4 9:15
 */
@WebServlet("/Userpage")
public class Userpage extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String number = request.getParameter("number");
        //String number=null;
        if (number == null) {
            number = String.valueOf(1);
        }
        System.out.println("Userpage:" + number);
        UserpageService userpage = new UserpageService();
        List<User> pages = userpage.pages(Integer.parseInt(number));
        System.out.println("web里的输出" + pages);
        request.setAttribute("users", pages);
        request.setAttribute("id", number);
        request.getRequestDispatcher("/list.jsp").forward(request, response);

    }
}
